var app=getApp()

Page({
  data: {
    map_height: 580,
    longitude: 116.396,
    latitude: 39.9102,
    markers: []
  },
  onLoad: function (e) {
    var that=this;
    // 动态设置map的宽和高
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          map_width: res.screenWidth,
          map_height: res.windowHeight
        })
      }
    })
  },
  onShow:function (e){
    var that = this;
    app.getLocationInfo(function(locationInfo){
      that.setData({
        longitude: locationInfo.longitude
        , latitude: locationInfo.latitude

            
      })
    })
    //取当前的地图上的恶臭点
    var stinkyObjs=[
      {
        id: 1,
        longitude: 116.396,
        latitude: 39.9102,
        stinkyType: '1',
        stinkyPower: '2',
        windDirec: "1",
        userName: '*斌',
        iconPath:"../../images/location.png",
        title:"..."
      }, {
        id: 3,
        longitude: 116.396,
        latitude: 39.9102,
        stinkyType: '1',
        stinkyPower: '2',
        windDirec: "1",
        userName: '*斌',
        iconPath: "../../images/location.png",
        title: "..."
      }, {
        id: 3,
        longitude: 116.396,
        latitude: 39.9102,
        stinkyType: '1',
        stinkyPower: '2',
        windDirec: "1",
        userName: '*斌',
        iconPath: "../../images/location.png",
        title: "..."
      },
    ]
    this.setData({ markers: stinkyObjs})
  },
  onReady: function (e) {
    this.mapCtx = wx.createMapContext('stinkyMap')
  },
  moveToLocation: function () {
    this.mapCtx.moveToLocation()
  },
  translateMarker: function () {
    this.mapCtx.translateMarker({
      markerId: 1,
      autoRotate: true,
      duration: 1000,
      destination: {
        longitude: 116.396,
        latitude: 39.9102
      },
      animationEnd() {
        console.log('animation end')
      }
    })
  },
  includePoints: function () {
    this.mapCtx.includePoints({
      padding: [10],
      points: [{
        latitude: 39.10229,
        longitude: 116.3345211
      }, {

        latitude: 39.10229,
          longitude: 116.3345211
      }]
    })
  },
  regionchange(e) {
    console.log("===============================")
  },
})
